package com.ysstech.distributed_quartz.job;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.ysstech.distributed_quartz.utils.DateUtils;

public class PrintCurrentTimeJobs extends QuartzJobBean{

	private static final Log LOG_RECORD = LogFactory.getLog(PrintCurrentTimeJobs.class);
	
	//这里就是因为有AutowiringSpringBeanJobFactory才可以使用@Autowired注解，否则只能在配置文件中设置这属性的值
	@Autowired
	private ClusterQuartz cluster;
	
	@Override
	protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException {
		LOG_RECORD.info("开始执行定时任务："+ DateUtils.format(new Date()));
		
		cluster.printUserInfo();
		
		LOG_RECORD.info("end to execute task," + DateUtils.format(new Date()));
	}

}
